﻿using RabbitMQ.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RabbitMqTest
{
    class Program
    {
        static void Main(string[] args)
        {
            var factory = new ConnectionFactory() { HostName = "localhost" };
            using (var connection = factory.CreateConnection())
            {
                using (var chanel = connection.CreateModel())
                {
                    chanel.QueueDeclare(queue: "hello", durable: false, exclusive: false, autoDelete: false, arguments: null);
                    string message = "Hello World";
                    var body = Encoding.UTF8.GetBytes(message);
                    for (int i = 0; i < 1000; i++)
                        chanel.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: Encoding.UTF8.GetBytes(i.ToString()));
                    Console.WriteLine("[x] send {0}", message);
                }
            }
            Console.WriteLine("Please [Enter] to exit.");
            Console.ReadLine();
        }
    }
}
